package com.qcxk.yuqian.system.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qcxk.yuqian.system.component.QueryWrapperConverter;
import com.qcxk.yuqian.system.entity.Userauthorder;
import com.qcxk.yuqian.system.mapper.UserauthorderMapper;
import com.qcxk.yuqian.system.service.IUserauthorderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @auther lp
 * @create 2021-05-24 02:34:15
 * @describe 存储每个用户自定义的一级菜单的顺序服务实现类
 */
@Service
public class UserauthorderServiceImpl extends ServiceImpl<UserauthorderMapper, Userauthorder> implements IUserauthorderService {
    @Autowired
    private UserauthorderMapper userauthorderMapper;

    @Override
    public Page queryUserauthorderPage(Page page, Userauthorder userauthorder) {

        QueryWrapper<Userauthorder> userauthorderQueryWrapper = new QueryWrapper<>();
        QueryWrapperConverter.converter(userauthorderQueryWrapper, userauthorder);

        userauthorderQueryWrapper.orderByDesc("ctime");
        userauthorderMapper.selectPage(page, userauthorderQueryWrapper);
        return page;
    }

    @Override
    public boolean deleteUserauthorderById(Userauthorder userauthorder) {
        int re = userauthorderMapper.deleteById(userauthorder.getId());
        return re == 1 ? true : false;
    }
}
